from rest_framework.generics import ListAPIView,ListCreateAPIView
from apps.meiduo_admin.serializers.user import UserModelSerializers
from apps.meiduo_admin.utils import PageNum
from apps.users.models import User


class UserGetListAPIView(ListCreateAPIView):
    serializer_class = UserModelSerializers

    pagination_class = PageNum

    # queryset =User.objects.all()
    def get_queryset(self):
        keyword = self.request.query_params.get('keyword')
        if keyword:
            return User.objects.filter(username__contains=keyword)
        return User.objects.all()


